import api from './auth';

// 获取广告列表
export const getAdvertisementList = (params) => {
  return api.get('/advertisement/list', { params });
};

// 条件搜索广告
export const searchAdvertisements = (params) => {
  return api.get('/advertisement/search', { params });
};

// 获取广告详情
export const getAdvertisementById = (adId) => {
  return api.get(`/advertisement/${adId}`);
};

// 创建广告
export const createAdvertisement = (data) => {
  return api.post('/advertisement', data);
};

// 更新广告
export const updateAdvertisement = (adId, data) => {
  return api.put(`/advertisement/${adId}`, data);
};

// 删除广告
export const deleteAdvertisement = (adId) => {
  return api.delete(`/advertisement/${adId}`);
};

// 发布广告
export const publishAdvertisement = (adId) => {
  return api.put(`/advertisement/${adId}/publish`);
};

// 下线广告
export const unpublishAdvertisement = (adId) => {
  return api.put(`/advertisement/${adId}/unpublish`);
};

// 获取当前有效的广告
export const getActiveAdvertisements = () => {
  return api.get('/advertisement/active');
};

// 获取指定位置的当前有效广告
export const getActiveAdvertisementsByPosition = (positionId) => {
  return api.get(`/advertisement/active/position/${positionId}`);
};

// 获取指定位置的当前有效广告（考虑时间段）
export const getActiveAdvertisementsByPositionAndTimeSlot = (positionId) => {
  return api.get(`/advertisement/active/position/${positionId}/timeslot`);
}; 